package org.lanyu.springainovel.common.dto;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * 自定义认证对象，扩展Spring Security的User�? * 添加用户ID字段，避免每次需要用户ID时都查询数据�? */
public class CustomUserDetails extends User {
    private Long userId;
    private String nickname;

    /**
     * 自定义用户详情构造函�?     * 
     * @param username 用户�?     * @param password 密码
     * @param enabled 账户是否启用
     * @param accountNonExpired 账户是否未过�?
     * @param credentialsNonExpired 凭证是否未过�?
     * @param accountNonLocked 账户是否未锁�?
     * @param authorities 用户权限集合
     * @param userId 用户ID
     * @param nickname 用户昵称
     */
    public CustomUserDetails(String username, String password, 
                           boolean enabled, boolean accountNonExpired, 
                           boolean credentialsNonExpired, boolean accountNonLocked, 
                           Collection<? extends GrantedAuthority> authorities,
                           Long userId, String nickname) {
        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
        this.userId = userId;
        this.nickname = nickname;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
}
